classdef classi
    properties
       density1
       density2
       label
       P
    end
    methods
        function c = classi(d1,d2,p)
            c.density1 = d1;
            c.density2 = d2;
            c.P = p;            
        end
        
        function [dat,dat1,dat2] = gen_data(c,n)
           randn('state',247776455);
           rand('state',247776455);
%           dat = [];
%            for i=1:n
%                num = rand(1,1);
%                if num < c.density1.a
%                   dat = [dat; c.density1.gen_data(1)];
%                else
%                   dat = [dat; c.density2.gen_data(1)];
%                end
%            end
           dat1 = c.density1.gen_data(floor(c.density1.a * n));
           dat2 = c.density2.gen_data(floor(c.density2.a * n));
           dat = [dat1;dat2];           
           idx = randperm(size(dat,1));
           dat = dat(idx,:);
        end
       
        function c = modify_M(c,alpha)
            m = c.density1.M;
            m1 = c.density1.M;
            m2 = c.density2.M;
            c.density1.M = alpha * m1+ (1-alpha) * m2;
        end
        
        function c = magnify_class(c,size)
            c.density1 = c.density1.magnify_density(size);
            c.density2 = c.density2.magnify_density(size);
        end
    end
end